package lee.study.TestSort;

import java.util.Arrays;

public class bubbleSort {

    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            boolean flg = false;
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j+1] < array[j]) {
                    int tmp = array[j+1];
                    array[j+1] = array[j];
                    array[j] = tmp;
                    flg = true;
                }
            }
        if (!flg){
            break;
        }
        }
    }

    public static void main(String[] args) {
        int[] array = {1, 7, 3, 9, 32, 94, 12, 64};
        bubbleSort(array);
        System.out.println(Arrays.toString(array));
    }
}
